package week06;

import java.util.Random;

public class TestPersonCmp {
    public static void main(String[] args) {
        Person[] personArray = new Person[10];
        Random rdm = new Random();
        for( int i=0; i<10; i++ ) {
            personArray[i] = new Person("Person"+i, rdm.nextInt(200), rdm.nextInt(100) );
        }
        for( int i=0; i<10; i++ )
            System.out.println(personArray[i].getName() + " " + personArray[i].getHeight());


        System.out.println("After sort:");


        AbstractPersonCmp cmpOp = new PersonCmpByHeight();
        cmpOp.sort(personArray);
        for( int i=0; i<10; i++ )
            System.out.println(personArray[i].getName() + " " + personArray[i].getHeight());


        // Another sorting method....
        /*
        Arrays.sort(personArray, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return 0;
            }
        });
        for( int i=0; i<10; i++ )
            System.out.println(personArray[i].getName() + " " + personArray[i].getHeight());
        */
    }
}
